package com.springbootblog.dao.sqlBuilder;

import com.springbootblog.pojo.User;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

public class UserSqlBuilder
{
    public String getUserByEmail(Map<String, Object> param)
    {
        String sql = "select * from user where email = '"+param.get("email")+"'";
        return sql;
    }

    public String getUserInfoById(Map<String, Object> param)
    {
        String sql = "select * from user where id = '"+param.get("id")+"'";
        //System.out.println(sql);
        return sql;
    }

    public String addUser(@NotNull User user)
    {
        String sql = "INSERT INTO user (java_password,email,regtime,logintime) " +
                "VALUES " +
                "('"+user.getPassword()+"','"+user.getEmail()+"',NOW(),NOW() )" ;
        return sql;
    }

    public String updateUserPassword(Map<String, Object> param)
    {
        String sql = "UPDATE user SET password = '"+param.get("password")+"' WHERE email = '"+param.get("email")+"'" ;
        return sql;
    }

    public String updateUserKey(Map<String, Object> param)
    {
        String sql = "UPDATE user SET user_login_key = '"+param.get("param1")+"' WHERE email = '"+param.get("param2")+"'" ;
        return sql;
    }

    public String updateUserNicknameById(Map<String, Object> param)
    {
        String sql = "UPDATE user SET nickname = '"+param.get("param2")+"' WHERE id = '"+param.get("param1")+"'" ;
        return sql;
    }



}
